package com.shan;

/**
 * @Author: ShanYuqing
 * @Version: v1.0
 */
public class Array2Test {
    public static void main(String[] args) {
        int[][] arr ={{11,22,33},{44,55,66}};
        printArray(arr);
        System.out.println("-------");
        getSum();
    }
    /*
            遍历并打印二维数组中的元素
            已知一个二维数组 arr ={{11,22,33},{44,55,66}}
            遍历该数组取出所有元素并打印
     */
    public static  void printArray(int[][] arr){
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                System.out.println(arr[i][j]);
            }
        }
    }
    /*
        遍历二维数组并求和
     */
    public static void getSum(){
        int[][] arr ={{11,22,33},{44,55,66}};
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                sum+=arr[i][j];
            }
            System.out.println(sum);
        }
    }
}
